'use strict';
const path = require('path');

function resolve(dir) {
    return path.join(__dirname, dir);
}

console.log('process.env.NODE_ENV', process.env.NODE_ENV);
console.log('process.env.ENV', process.env.ENV);

const name = 'ai_draw_me';

module.exports = {
    publicPath: process.env.NODE_ENV === 'development' ? './' : 'https://qncdn.mozigu.net/apps/jror5y1x',
    outputDir: 'dist',
    assetsDir: 'static',
    lintOnSave: process.env.NODE_ENV === 'development',
    productionSourceMap: false,
    configureWebpack: {
        name: name,
        resolve: {
            alias: {
                '@': resolve('src'),
            },
        },
    },
    pages: {
        index: {
            entry: 'src/main.js',
            template: 'src/index.html',
            filename: 'index.html',
            title: 'ai_draw_me',
        },
    },
    devServer: {
        port: 8081,
        open: false,
        overlay: {
            warnings: false,
            errors: true,
        },
        proxy: {
            '/make_img': {
                target: 'https://api.ali-fc.moapp.net.cn',
                changeOrigin: true,
                logLevel: 'debug',
                rewrite: {
                    '^/make_img': '',
                },
            },
        },
    },
    pluginOptions: {
        'style-resources-loader': {
            preProcessor: 'less',
            patterns: [path.resolve(__dirname, './src/style/global.less')],
        },
    },
};
